package com.gkj.gulimall.product.web;

import com.gkj.gulimall.product.entity.CategoryEntity;
import com.gkj.gulimall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    CategoryService categoryService;
    @GetMapping({"/","/index.html"})
    public String indexPage(Model model){
        //查出所有的一级分类
        List<CategoryEntity> list = categoryService.getLevel1Categorys();
        list.forEach((t) -> {
            System.out.println(t);
        });
        model.addAttribute("category",list);
        //视图解析器进行拼串
        return "index";
    }
}
